<?php
/*
	招商中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['ischecklogin']=$this->model('member')->checklogin();
if($_RQ['op']=='main'){
	$_SESSION['forward_url']='jy_kuaidisys/agent/';
	$return['setting']=$this->plugin_setting('page');
	set_html('title',$return['setting']['agent_center']?:'分销员中心');
	$member=$this->get('member',array('mid'=>$_SESSION['uid']));
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	if($member['level_id']){
		$member['level']=$this->getcolumn('level',array('id'=>$member['level_id']),'title');
	}else{
		$member['level']='普通等级';
	}
	$return['ordernum']=$this->count('commission',array('mid'=>$_SESSION['uid']));
	$return['member']=$member;
	$data=array();
	$data['order_num']=$return['ordernum'];
	//已结算佣金
	$data['balance_total']=$this->sum('balance',array('mid'=>$_SESSION['uid']),'money');
	$data['balance_num']=$this->count('balance',array('mid'=>$_SESSION['uid']));
	$data['agent_num']=pdo_count('jy_kuaidisys_member',array('fromuser'=>$member['mid']));
	//待结算佣金
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1);
	/*if($this->setting['balance_day']){
		//结算天数
		$time=TIMESTAMP-intval($this->setting['balance_day'])*86400;
		$params['complete_time <']=$time;
	}*/
	$data['commission_1']=$this->sum('commission',$params,'money');
	$data['commission_total']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'money');
	$return['data']=$data;
	$return['rank']=$this->plugin_setting('rank');
	exi($return);
}
?>